<script setup>
import {useRoute, useRouter} from "vue-router";

const list = [
  {
    title: "组件",
    index: "1",
    list: [
      {
        name: "聊天组件",
        url: "/component/chat",
        index: "chat"
      },
      {
        name: "展开收起",
        url: "/component/expand",
        index: "expand"
      },
      {
        name: "通知小红点",
        url: "/component/badge",
        index: "badge"
      }
    ]
  },
  {
    title: "功能",
    index: "2",
    list: [
      {
        name: "生成增删改查",
        url: "/function/crud",
        index: "crud"
      },
      {
        name: "数字金额大小写转换",
        url: "/function/priceNumber",
        index: "priceNumber"
      },
    ]
  },
  {
    title: "摸🐟",
    index: "3",
    list: [
      {
        name: "扫雷",
        url: "/fish/saolei",
        index: "saolei"
      },
      {
        name: "2048",
        url: "/fish/game2048",
        index: "game2048"
      },
      // {
      //   name: "消消乐",
      //   url: "/fish/xiaoxiaole",
      //   index: "xiaoxiaole"
      // },
    ]
  }
]
const router = useRouter()
const route = useRoute()

function goTo(index) {
  router.push(index)
}
</script>

<template>
  <div class="common-layout">
    <el-container>
      <el-header>
        <div class="h-full flex items-center text-white font-bold">前端工具箱</div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
              :default-active="route.name"
              class="el-menu-vertical-demo"
          >
            <el-sub-menu :index="items.index" v-for="items in list" :key="items.index">
              <template #title>
                <span>{{ items.title }}</span>
              </template>
              <el-menu-item v-for="item in items.list" :key="item.index" :index="item.index" @click="goTo(item.url)">
                {{ item.name }}
              </el-menu-item>
            </el-sub-menu>

          </el-menu>
        </el-aside>
        <el-main>
          <slot name="main"></slot>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style lang="scss" scoped>
.common-layout {
  width: 100%;
  height: 100vh;
}

.el-header{
  @apply bg-blue-500;
}
</style>